<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>promiseAPI使用</title>
</head>
<body>
    <script>

        var promise = new Promise(function(resolved,reject){
            // 失败状态下的catch和finally；需要参数
            reject("报错");
        })
        promise.then(function(){
            console.log("成功,then")
        },function(){
            console.log("失败,then")
        })
        // 只会捕获失败后执行
        promise.catch(function(){
            console.log("失败,catch")
        })
        // 无论成功失败都会执行
        promise.finally(function(){
            console.log("完成,finally")
        })
    </script>
</body>
</html>